package cn.edu.nuc.ssm.service.impl;

import cn.edu.nuc.ssm.dao.DoListMapper;
import cn.edu.nuc.ssm.entity.DoList;
import cn.edu.nuc.ssm.service.DoListService;
import cn.edu.nuc.ssm.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2017/4/10.
 */
@Service
public class DoListServiceImpl implements DoListService {

    @SuppressWarnings("SpringJavaAutowiringInspection")
    @Autowired
    private DoListMapper doListMapper;

    @Override
    @Transactional(readOnly = true,timeout = 30)
    public List<DoList> findbyUseIdAndRecordDateBetweenOrEqualTo(int useId, String minRecordDate, String maxRecordDate) {

        if (minRecordDate==null||"".equals(minRecordDate)){
            minRecordDate= DateUtil.getCurrentMouthFirstDay();
        }
        if (maxRecordDate==null||"".equals(maxRecordDate)){
            maxRecordDate = DateUtil.getCurrentMouthLastDay();
        }

        return doListMapper.findbyUseIdAndRecordDateBetweenOrEqualTo(useId,minRecordDate,maxRecordDate);
    }
}
